<div class="main-content">
	
	<!-- Main content -->
    <div class="page-content">
    	<div class="row">
    		<div class="page-header">
    			<h1>计划管理</h1>
    		</div>
		</div>
		<div class="col-xs-12 margin_t margin_b">
			<div class="table-responsive  tab">
				<table id="sample-table-1" class="table table-striped table-bordered table-hover">
					<tr>
						<th>油站名称</th>
						<th>油号</th>
						<th>原价</th>
						<th>发布价</th>
						<th>降幅</th>
						<th>生效时间</th>
						<th>操作</th>
					</tr>
					<?php foreach($result as $row):?>
						<tr>
							<td><?php echo $row['gasstation_name']?></td>
							<td><?php echo $row['oil_no']?></td>
							<td><?php echo $row['old_yz_price']?></td>
							<td><?php echo $row['yz_price']?></td>
							<td>
								<?php if($row['de_price'] < 0):?>
									<span style="color: red"><?php echo $row['de_price'];?></span>
								<?php else:?>
									<span style="color: green"><?php echo $row['de_price'];?></span>
								<?php endif?>
							</td>
							<td><?php echo $row['effective_time']?></td>
							<td><button class="btn btn-danger btn-sm" onclick="cancel(<?php echo $row['id']?>,<?php echo $row['gm_id']?>)">撤销</button></td>
						</tr>
					<?php endforeach?>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="cancel" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>确认要撤销改计划吗？</p>
			</div>
			<div class="modal-footer">
			  <button id="cancel_btn" type="submit" gid='' gmid ='' class="btn btn-danger">确定</button>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function cancel(gid,gmid){
	    $('#cancel').modal('show');
	    $('#cancel_btn').attr('gid',gid);
	    $('#cancel_btn').attr('gmid',gmid);
	}
	$('#cancel_btn').click(function(){
		var id = $(this).attr('gid');
		var gm_id = $(this).attr('gmid');
		if(id == ''){
			alert('id不能为空');
			return;
		}
		if(gm_id == ''){
			alert('id不能为空');
			return;
		}
		$.post("<?php echo base_url().'/admin/gasstation/cancel_plan'?>",{
			id:id,
			gm_id:gm_id
		},function(res){
			if(res){
				location.reload();
			}else{
				alert('撤销失败！');
			}
		})
	})
</script>